package pers.sports.service.impl;

import org.springframework.stereotype.Service;
import pers.sports.dao.ApplyDao;
import pers.sports.service.ApplyService;
import pers.sports.vo.ApplyDetailed;
import pers.sports.vo.VolunteerInfo;

import java.util.List;

/**
 * 报名信息
 *
 * @datetime 2021/4/25 14:31
 */

@Service
public class ApplyServiceImpl implements ApplyService {

    private final ApplyDao applyDao;

    public ApplyServiceImpl(ApplyDao applyDao) {
        this.applyDao = applyDao;
    }

    @Override
    public List<ApplyDetailed> findApplyInfo(Integer page, Integer limit, Integer review) {
        Integer b = (page-1)+((page-1)*limit);
        return applyDao.findApplyInfo(b, limit, review);
    }

    @Override
    public Boolean updateReview(Integer id, Integer review) {
        if (review == 1){
            applyDao.insertScoreByApplyId(id);
        }else {
            applyDao.deleteScoreByApplyId(id);
        }
        return applyDao.updateReview(id, review) != 0 ? true : false;
    }

    @Override
    public List<ApplyDetailed> findSelfApply(String stuId) {
        return applyDao.findSelfApply(stuId);
    }

    @Override
    public void deleteById(String applyId) {
        applyDao.deleteById(applyId);
    }

    @Override
    public List<String> getReviewPass() {
        return applyDao.getReviewPass();
    }

    @Override
    public Boolean insertVolunteer(String stuId) {
        return applyDao.insertVolunteer(stuId)!=0?true:false;
    }

    @Override
    public Boolean findVolunteerByStuId(String stuId) {
        return applyDao.findVolunteerByStuId(stuId)==0?true:false;
    }

    @Override
    public List<VolunteerInfo> findAllVolunteer() {
        return applyDao.findAllVolunteer();
    }
}
